#ifndef NODE_H
#define NODE_H


#include <QDateTime>
#include <QVector>
#include <QSharedPointer>
#include <QDir>
#include <QEnableSharedFromThis>

#include "global.h"

namespace stitch
{

// Node of notebook.
class Node : public QEnableSharedFromThis<Node>
{
public:
    enum Flag {
        None = 0,
        // A node with content.
        Content = 0x1,
        // A node with children.
        Container = 0x2,
        ReadOnly = 0x4,
        // Whether a node exists on disk.
        Exists = 0x10
    };
    Q_DECLARE_FLAGS(Flags, Flag)

    enum Use {
        Normal,
        Root
    };

    enum { InvalidId = 0 };


private:
    void checkSignature();

    Flags m_flags = Flag::None;

    Use m_use = Use::Normal;

    ID m_id = InvalidId;

    // A long random number created when the node is created.
    // Use to avoid conflicts of m_id.
    ID m_signature = InvalidId;

    QString m_name;

    QDateTime m_createdTimeUtc;

    QDateTime m_modifiedTimeUtc;

    QStringList m_tags;

    QString m_attachmentFolder;

    Node *m_parent = nullptr;

    QVector<QSharedPointer<Node>> m_children;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(Node::Flags)
} //

#endif // NODE_H
